All Questions
Tagged with coding-standardsclean-code
24 questions
-1votes
1answer
196views
What is point of having certain microservices making another API call in the same service
I was going through an old, largely untouched part in my company’s codebase and found one API. It does the following things. A POST API with path host/entities/trigger which fetches a list of entity ...
0votes
5answers
198views
best practice for error handling between PAM_SUCCESS and PAM_AUTH_ERR macros
We have two exit code code PAM_SUCCESS(0), PAM_AUTH_ERR(7). If we wanna return 0 or 7 when we compared password with our password in following code which code is better that this code ? if (strcmp (...
-2votes
1answer
528views
Assumptions versus no assumptions - where do you draw the line? [closed]
In our line of work as software engineers, we can write code that assumes various things outside its scope or architectural boundary, in order to save performance, time, and on defensive coding ...
0votes
2answers
268views
Should we put behaviors (method) in constant class in Java?
Should we put behaviors (method) in constant class in Java? If not then why? Which clean code practice/principle I am breaking while doing that? public class TagConstants { public static final ...
4votes
5answers
386views
Two different styles of functions: does either have an advantage?
In the past few months that I've been learning Javascript, I've wondered which is the better usage of functions: Functions that perform actions based on their arguments with no return value: const ...
0votes
2answers
539views
Should default settings be considered as business rules from the viewpoint of "Clean Architecture"?
The examples of default settings: Default port for server applications Default resources directory for Java Applications Default Webpack config file ("webpack.config.js") My particular ...
1vote
1answer
206views
counting identifiers and operators as code size metric
I'm looking for a code metric for monitor and track over time the size of several projects and their components. Also, I would like to use it for: evaluate size reduction after refactoring compare ...
1vote
1answer
440views
Cyclomatic complexity vs repeated code
we've a python function that can be achieved in 2 ways 1st method def complexity_1(x, y): if 2 == x and 3 == y: a=3 b=4 c = a + b elif 2 == x and not 3 == y: a =...
2votes
2answers
660views
Does it make sense to use meaningless named constants?
For example, does it make sense to refactor the following code: a = a * 2; as: const int INT_TWO = 2; // ... a = a * INT_TWO; My question hinges on the fact that the new constant conveys no extra ...
4votes
4answers
345views
Measuring the success of coding dojos
I'm interested in starting coding dojos at the company I work at (during or after working hours). I think it will help to spread knowledge on how to write clean, concise and consistent code. I've been ...
12votes
5answers
2kviews
How to introduce new language features in a legacy source code?
I have a coding style related question. In my example it is java, but I think this can be a generic question regarding languages that are changing rapidly. I'm working on a java code base which was ...
21votes
6answers
4kviews
How to quantify Code Quality [closed]
My Business unit has huge number of developers (About 100). Due to various reasons, the developers are nearly solely focused on delivery rather than quality. The bad quality code has already started ...
1vote
3answers
1kviews
How should I name output variables that are the same as the function?
What are some conventions for naming a variable in cases where the name of the variable ought to be identical to the name of the function? I'm using VB.Net. I often have this problem when writing ...
1vote
3answers
319views
Which option is best, when you have an attribute that is a list?
I have a class containing a list, for example: class User{ .... List<String> cards ... } What's the best way to provide access to this member? List<String> getCards() or String ...
4votes
1answer
4kviews
Node.js script const variables in SCREAMING_SNAKE_CASE or camelCase
TL/DR: When requiring another script in Node.js and defining it as a const should the variable name still be in camelCase like it was usual with var or should it instead be in SCREAMING_SNAKE_CASE as ...